package indvi.cfeng.persistencedemo.repository;

import indvi.cfeng.persistencedemo.entity.VeUser;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author Cfeng
 * @date 2022/7/17
 */

public interface VeUserRepository extends CrudRepository<VeUser,Integer>, JpaSpecificationExecutor<VeUser> {
    //按照规范书写相关方法名
    List<VeUser> findByUserName(String userName);

    //查询比height高的用户
    VeUser findByHeightGreaterThan(BigDecimal height);

    //SQL
    //下面这个方法名没有遵循关键字的规范
    @Query(nativeQuery = true,value = "select ve_name from ve_user where (create_time between ? and ?)  and  ve_name like ?")
    List<VeUser> queryByTimeAndName(LocalDateTime start,LocalDateTime end,String keyWord);
}
